package edu.ncsu.csc;

public class Statistics {
	private int[] samples = new int[256];
	private long time = System.currentTimeMillis();
	
	public void reset() {
		for (int i = 0; i < samples.length; i++) samples[i] = 0;
		time = System.currentTimeMillis(); 
	}
	
	public void sampleReceived(byte sensorID) {
		samplesReceived(sensorID, 1);
	}

	public void samplesReceived(byte sensorID, int num) {
		samples[sensorID] += num;
	}

	public void dumpStats() {
		long curTime = System.currentTimeMillis();
		
		System.out.println("Sampling Rates:");
		for (int spot = 0; spot < 8; spot++) {
			System.out.println(" SPOT " + spot);
			for (int sensorInd = 0; sensorInd < 8; sensorInd++) {
				int sensorID = (spot << 3) + sensorInd;
				if (samples[sensorID] > 0) System.out.println("  Sensor " + sensorID + ": " + (float)(samples[sensorID]*1024)/(float)(curTime-time));
			}
		}
		System.out.println();

	}
}
